<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>信审通过意见</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<form id="formSet1">
			<div class="fieldset1 tabel_col clearFix">
				<div class="caption">
					<span class="title">信审资料及承租人资质</span>
				</div>
				<div class="fieldBox col_100">
					<span>承租人</span>
				</div>
				<div class="fieldBox col_33">
					<div class="label">信审资料</div>
					<div class="field">
						<input name="creditInfo_tenant" id="creditInfo_tenant" type="text" class="ui-textbox" value="" >
						<input name="extId_tenant" id="extId_tenant" type="hidden" value="">
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">资质情况</div>
					<div class="field">
						<input name="qualificationsInfo_tenant" id="qualificationsInfo_tenant" type="text" class="ui-textbox" value="" >
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">资产证明</div>
					<div class="field">
						<select name="assetsProveCd_tenant" id="assetsProveCd_tenant" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${assetsProveCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">融资次数</div>
					<div class="field">
						<input name="times_tenant" id="times_tenant" type="text" class="ui-textbox" value="" validate="{number:true}">
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">不良记录情况</div>
					<div class="field">
						<input name="badRecordInfo_tenant" id="badRecordInfo_tenant" type="text" class="ui-textbox" value="" >
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">法院执行情况</div>
					<div class="field">
						<input name="courtsEnforceInfo_tenant" id="courtsEnforceInfo_tenant" type="text" class="ui-textbox" value="" >
					</div>
				</div>
				<!-- 承租人资料动态页面  区分:自然人/法人 -->
				<div id="TenantDiv" class="fieldBox col_100_auto">
					<%-- <jsp:include page="audPassOpinionTenantDycPage.jsp"></jsp:include> --%>
				</div>
				<div class="fieldBox col_100">
					<span>担保人</span>
				</div>
				<div class="fieldBox col_33">
					<div class="label">信审资料</div>
					<div class="field">
						<input name="creditInfo_guarantor" id="creditInfo_guarantor" type="text" class="ui-textbox" value="" >
						<input name="extId_guarantor" id="extId_guarantor" type="hidden" value="">
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">资质情况</div>
					<div class="field">
						<input name="qualificationsInfo_guarantor" id="qualificationsInfo_guarantor" type="text" class="ui-textbox" value="" >
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">资产证明</div>
					<div class="field">
						<select name="assetsProveCd_guarantor" id="assetsProveCd_guarantor" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${assetsProveCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">与承租人关系</div>
					<div class="field">
						<select name="relationshipCd_guarantor" id="relationshipCd_guarantor" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${relationshipCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<!-- 担保人资料模块 动态字段 区分:自然人/法人 -->
				<div id="GuarantorDiv" class="fieldBox col_100_auto">
					<%-- <jsp:include page="audPassOpinionGuarantorDycPage.jsp"></jsp:include> --%>
				</div>
				
				<div class="caption">
					<span class="title">产品政策</span>
				</div>
				<div class="fieldBox col_33">
					<div class="label">收益率</div>
					<div class="field">
						<input name="returnPct" id="returnPct" type="text" class="ui-textbox" data-tofix="2" validate="{number:true}">
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">执行政策标准</div>
					<div class="field">
						<select name="policyStandatrdsCd" id="policyStandatrdsCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${policyStandatrdsCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">是否符合标准</div>
					<div class="field">
						<select name="standardCd" id="standardCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${standardCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">执行模板</div>
					<div class="field">
						<select name="executeTemplateCd" id="executeTemplateCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${executeTemplateCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				
				<div class="caption">
					<span class="title">运营分析</span>
				</div>
				<div class="fieldBox col_100">
                    <div class="label">运营分析</div>
                    <div class="field" style="width: 100%;">
                        <textarea name="operationAnalysis" id="operationAnalysis" rows="4" class="l-textarea" style="width:99%" value="" ></textarea>
                    </div>
                </div>
                
				<div class="caption">
					<span class="title">信审员评价</span>
				</div>
				<div class="fieldBox col_100">
					<span>承租人</span>
				</div>
	            <div class="fieldBox col_33">
					<div class="label">购车行为</div>
					<div class="field">
						<select name="buyCd" id="buyCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${buyCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
	            <div class="fieldBox col_33">
					<div class="label">资产实力</div>
					<div class="field">
						<select name="lesseeAssetsCd" id="lesseeAssetsCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${lesseeAssetsCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
	            <div class="fieldBox col_33">
					<div class="label">车辆配置</div>
					<div class="field">
						<select name="carConfigCd" id="carConfigCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${carConfigCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
	            <div class="fieldBox col_33">
					<div class="label">融资方案</div>
					<div class="field">
						<select name="financePlanCd" id="financePlanCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${financePlanCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
	            <div class="fieldBox col_33">
					<div class="label">运营情况</div>
					<div class="field">
						<select name="operationSituationCd" id="operationSituationCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${operationSituationCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
	            <div class="fieldBox col_33">
					<div class="label">运营经验</div>
					<div class="field">
						<select name="operationExperienceCd" id="operationExperienceCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${operationExperienceCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
	            <div class="fieldBox col_33">
					<div class="label">第二还款来源</div>
					<div class="field">
						<select name="paymentSourceCd" id="paymentSourceCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${paymentSourceCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">经营状况</div>
					<div class="field">
						<input name="managementSituation" id="managementSituation" type="text" class="ui-textbox" value="" >
					</div>
				</div>
				<div class="fieldBox col_100">
					<span>担保人</span>
				</div>
				<div class="fieldBox col_33">
					<div class="label">履行职责</div>
					<div class="field">
						<select name="fulfilCd" id="fulfilCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${fulfilCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">资产实力</div>
					<div class="field">
						<select name="guarantorAssetsCd2" id="guarantorAssetsCd2" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${lesseeAssetsCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="caption">
					<span class="title">风险</span>
				</div>
				<div class="fieldBox col_33">
					<div class="label">电话态度</div>
					<div class="field">
						<select name="attitudeCd" id="attitudeCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${attitudeCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">风险分析</div>
					<div class="field">
						<input name="riskAnalysis" id="riskAnalysis" type="text" class="ui-textbox" value="" >
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">可操作性评价</div>
					<div class="field">
						<select name="maneuverabilityCd" id="maneuverabilityCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${maneuverabilityCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">审批意见结束语</div>
					<div class="field">
						<input name="opinion" id="opinion" type="text" class="ui-textbox" value="" >
					</div>
				</div>
				
				<div id="car" class="caption" style="display: none">
					<span class="title">其他信息</span>
				</div>
				<div id="CarDiv" class="fieldBox col_100_auto">
					<jsp:include page="audPassOpinionCarDycPage.jsp"></jsp:include>
				</div>
				
				<div class="caption">
					<span class="title">备注</span>
				</div>
				<div class="fieldBox col_100">
                    <div class="label">备注</div>
                    <div class="field" style="width: 100%;">
                        <textarea name="otherInfo" id="otherInfo" rows="4" class="l-textarea" style="width:99%" value="" ></textarea>
                    </div>
                </div>
			</div>
			<div class="btnsBox">
				<span id="saveBtn1" class="sq-button sq-button-round" onclick="saveAudPassOpn();">保存</span> 
				<span id="previewBtn" class="sq-button sq-button-round" onclick="getPreviewString();">预览</span> 
				<input name="creditPassOpinionId" id="creditPassOpinionId" type="hidden" value="${id }">
			</div>
		</form>
	</div>

<script type="text/javascript">
var _projectId = '${projectId}';//项目ID
var _proIntId = '${proIntId}';//流程实例ID
var _tenantTypCd = '${tenantTypCd}';//承租人类型
var _guarantorTypCd = '${guarantorTypCd}';//担保人类型
var _prdTypCd = '${prdTypCd}';//产品类型

var mainData;//信审通过意见主数据

$(function(){
	$('#formSet1').ligerForm({
        validate : true
	});
	initData();
	SET_popupIframeHeight();
});

//预览
function getPreviewString(){
	var creditPassOpinionId = $("#creditPassOpinionId").val();
	if(StringUtils.isEmpty(creditPassOpinionId)){
		$.ligerDialog.SQalert({content: "请先保存信息!" , SQ_type: "warning" });
		return;
	}
	top.$.ligerDialog.SQopen({
        width: 900,
        height:500,
        top:200,
        title : '预览',
        url:'<%=path%>/audit/audCreditPassOpinion/toPreviewPage.do?id='+creditPassOpinionId,
        buttons: [
                {
	            text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no',
	            onclick: function (item, Dialog) {
	                if (Dialog.onCancel) Dialog.onCancel();
	            }
	        }
	    ]
    });
}

//刷新承租人资料模块
function refreshTenantDyncFild(){
	if(!_tenantTypCd || _tenantTypCd=='') return;
	var _bizTypCd = "CST0001";
	var _bizCd = _tenantTypCd;
	var _url_1 = '<%=path%>/audit/audCreditPassOpinion/toTenantDynamicFldPage.do';
	$("#TenantDiv").load(_url_1,{bizTypCd:_bizTypCd, bizCd:_bizCd},function(responseText,textStatus){
		$("#formSet1").check_ligerFormEditor();
		setTenantData();
	});
}
//刷新担保人资料模块
function refreshGuarantorDyncFild(){
	if(!_guarantorTypCd || _guarantorTypCd=='') return;
	var _bizTypCd = "CST0001";
	var _bizCd = _guarantorTypCd;
	var _url_1 = '<%=path%>/audit/audCreditPassOpinion/toGuarantorDynamicFldPage.do';
	$("#GuarantorDiv").load(_url_1,{bizTypCd:_bizTypCd, bizCd:_bizCd},function(responseText,textStatus){
		$("#formSet1").check_ligerFormEditor();
		setGuarantorData();
	});
}
//刷新乘用车增加模块
function refreshCarDyncFild(){
	if(!_prdTypCd || _prdTypCd=='') return;
	var _bizTypCd = "PRD0001";
	var _bizCd = _prdTypCd.substring(0,3);
	var _url_1 = '<%=path%>/audit/audCreditPassOpinion/toCarDynamicFldPage.do';
	$("#CarDiv").load(_url_1,{bizTypCd:_bizTypCd, bizCd:_bizCd},function(responseText,textStatus){
		$("#formSet1").check_ligerFormEditor();
		if($("#quantities").length){
			$("#car").show();
		}
		setCarData();
	});
}

//请求数据(参数:项目ID,流程实例ID)
function initData(){
	if(!_projectId || !_proIntId){
		return;
	}
   	var _url = '<%=path%>/audit/audCreditPassOpinion/getByProjectIdAndProIntId.do';
	$.ajax({
   		type: 'get',
   		dataType:'json',
   		data:{
   			projectId:_projectId,
   			proIntId:_proIntId
   		},
   		url: _url,
   		success:function(msg){
			if(msg.success == 1){
				setData(msg.data);//设置数据
   				mainData = msg.data;
			}else{
				$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
			}
			refreshTenantDyncFild();
			refreshGuarantorDyncFild()
			refreshCarDyncFild();
		}
	});
}

//设置页面数据
function setData(data){
	var form = liger.get("formSet1");
	
	$("#creditPassOpinionId").val(data.id);//信审通过意见ID
	var tenantAudCreditExtInfoVO = data.tenantAudCreditExtInfoVO;//承租人扩展信息
	var guarantorAudCreditExtInfoVO = data.guarantorAudCreditExtInfoVO;//担保人扩展信息
	
	if(tenantAudCreditExtInfoVO){
		$("#extId_tenant").val(tenantAudCreditExtInfoVO.id);//承租人扩展信息ID
		$("#creditInfo_tenant").val(tenantAudCreditExtInfoVO.creditInfo);
		$("#qualificationsInfo_tenant").val(tenantAudCreditExtInfoVO.qualificationsInfo);
		$("#times_tenant").val(tenantAudCreditExtInfoVO.times);
		$("#badRecordInfo_tenant").val(tenantAudCreditExtInfoVO.badRecordInfo);
		$("#courtsEnforceInfo_tenant").val(tenantAudCreditExtInfoVO.courtsEnforceInfo);
		form.setData({
			assetsProveCd_tenant:tenantAudCreditExtInfoVO.assetsProveCd
		});
	}
	if(guarantorAudCreditExtInfoVO){
		$("#extId_guarantor").val(guarantorAudCreditExtInfoVO.id);//担保人扩展信息ID
		$("#creditInfo_guarantor").val(guarantorAudCreditExtInfoVO.creditInfo);
		$("#qualificationsInfo_guarantor").val(guarantorAudCreditExtInfoVO.qualificationsInfo);
		form.setData({
			assetsProveCd_guarantor:guarantorAudCreditExtInfoVO.assetsProveCd,
			relationshipCd_guarantor:guarantorAudCreditExtInfoVO.relationshipCd
		});
	}
	
	$("#returnPct").val(data.returnPct);
	$("#operationAnalysis").val(data.operationAnalysis);
	$("#managementSituation").val(data.managementSituation);
	$("#riskAnalysis").val(data.riskAnalysis);
	$("#opinion").val(data.opinion);
	$("#otherInfo").val(data.otherInfo);
	form.setData({
		policyStandatrdsCd:data.policyStandatrdsCd,
		standardCd:data.standardCd,
		executeTemplateCd:data.executeTemplateCd,
		buyCd:data.buyCd,
		lesseeAssetsCd:data.lesseeAssetsCd,
		carConfigCd:data.carConfigCd,
		financePlanCd:data.financePlanCd,
		operationSituationCd:data.operationSituationCd,
		operationExperienceCd:data.operationExperienceCd,
		paymentSourceCd:data.paymentSourceCd,
		fulfilCd:data.fulfilCd,
		guarantorAssetsCd2:data.guarantorAssetsCd2,
		attitudeCd:data.attitudeCd,
		maneuverabilityCd:data.maneuverabilityCd,
	});
};
//设置承租人动态字段数据
function setTenantData(){
	if(!mainData) return;
	var form = liger.get("formSet1");
	var tenantAudCreditExtInfoVO = mainData.tenantAudCreditExtInfoVO;//承租人扩展信息
	if(tenantAudCreditExtInfoVO){
		$("#researchReport_tenant").val(tenantAudCreditExtInfoVO.researchReport);
		$("#job_tenant").val(tenantAudCreditExtInfoVO.job);
		$("#business_tenant").val(tenantAudCreditExtInfoVO.business);
		if(tenantAudCreditExtInfoVO.registerTm){
    		var date = new Date(tenantAudCreditExtInfoVO.registerTm);
    		var dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
    		$("#registerTm_tenant").val(dateStr);
    	}
	}
};
//设置担保人动态字段数据
function setGuarantorData(){
	if(!mainData) return;
	var form = liger.get("formSet1");
	var guarantorAudCreditExtInfoVO = mainData.guarantorAudCreditExtInfoVO;//担保人扩展信息
	if(guarantorAudCreditExtInfoVO){
		$("#researchReport_guarantor").val(guarantorAudCreditExtInfoVO.researchReport);
		$("#job_guarantor").val(guarantorAudCreditExtInfoVO.job);
		$("#business_guarantor").val(guarantorAudCreditExtInfoVO.business);
		if(guarantorAudCreditExtInfoVO.registerTm){
    		var date = new Date(guarantorAudCreditExtInfoVO.registerTm);
    		var dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
    		$("#registerTm_guarantor").val(dateStr);
    	}
	}
};
//设置乘用车动态字段数据
function setCarData(){
	if(!mainData) return;
	var form = liger.get("formSet1");
	$("#quantities").val(mainData.quantities);
	$("#brandModel").val(mainData.brandModel);
	$("#marketPrice").val(mainData.marketPrice);
	$("#chinaLowestPrice").val(mainData.chinaLowestPrice);
	$("#provinceLowestPrice").val(mainData.provinceLowestPrice);
	$("#localLowestPrice").val(mainData.localLowestPrice);
	$("#systemPrice").val(mainData.systemPrice);
	if(mainData.registrationDt){
   		var date = new Date(mainData.registrationDt);
   		var dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
   		$("#registrationDt").val(dateStr);
   	}
	$("#mileage").val(mainData.mileage);
	$("#display").val(mainData.display);
	$("#certificates").val(mainData.certificates);
	$("#incomeExpenditure").val(mainData.incomeExpenditure);
	$("#overdueInfo").val(mainData.overdueInfo);
	$("#liabilitiesInfo").val(mainData.liabilitiesInfo);
	$("#guarantInfo").val(mainData.guarantInfo);
	
	form.setData({
		isCarStandard:mainData.isCarStandard,
		assetsProveCd:mainData.assetsProveCd,
		isInquiry:mainData.isInquiry,
		isCreditStandard:mainData.isCreditStandard,
	});
};


function saveAudPassOpn(){
	var form = liger.get("formSet1");
    if (!form.valid()) {
    	$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
        return false; //验证不通过，不执行以下代码
    }
    var data = form.getData();
    data["projectId"] = _projectId;//项目ID
    data["proIntId"] = _proIntId;//流程实例ID
    data["extId_tenant"] = $("#extId_tenant").val();
    data["extId_guarantor"] = $("#extId_guarantor").val();
    
    var id = $("#creditPassOpinionId").val();
    var url = '<%=path%>/audit/audCreditPassOpinion/add.do';
    if(id != ""){
    	url = '<%=path%>/audit/audCreditPassOpinion/modify.do';
    	data["id"]= id;
    }
   var wait_dialog;
    $.ajax({
		type: 'post',
		dataType:'json',
		data:data,
		url: url,
		beforeSend: function(){
	          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
	     },
		success:function(msg){
			 wait_dialog.close();
			 if(msg.success == 1){
				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
				 if(msg.data){
					 $("#creditPassOpinionId").val(msg.data);
				 }
			 }else{
				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
			 }
		}
	});
}

</script>



</body>
</html>
